package report

import (
	"gorm.io/plugin/soft_delete"
	"xkginweb/global"
)

// 上报情况表

type QccReport struct {
	ReportId    uint                  `gorm:"primary_key;AUTO_INCREMENT;comment:主键ID" json:"report_id"`
	CreatedAt   global.LocalTime      `gorm:"type:datetime;comment:创建时间" json:"created_at"`
	UpdatedAt   global.LocalTime      `gorm:"type:datetime;comment:更新时间" json:"updated_at"`
	IsDeleted   soft_delete.DeletedAt `gorm:"type:bigint(20) unsigned;default:0;comment:是否删除" json:"is_deleted"`
	ReportName  string                `gorm:"type:varchar(50);comment:巡检名;default:'';NOT NULL" json:"report_name"`
	RoomId      uint                  `gorm:"type:bigint(20);comment:房间id;default:0;NOT NULL" json:"room_id"`
	ReporterId  uint                  `gorm:"type:bigint(20);comment:上报人id;default:0;NOT NULL" json:"reporter_id"`
	Status      string                `gorm:"type:varchar(50);default:'正常';comment:房间状态 1正常 2异常 3故障 4其他" json:"status"`
	Detail      string                `gorm:"type:text;comment:报修详情;NOT NULL" json:"detail"`
	QccRoom     *QccRoom              `gorm:"foreignKey:RoomId;references:room_id;" json:"room"`
	QccReporter *QccReporter          `gorm:"foreignKey:ReporterId;references:reporter_id;" json:"reporter"`
}

func (QccReport) TableName() string {
	return "qcc_report"
}

type QccRoom struct {
	RoomId   uint   `json:"room_id" gorm:"primarykey;comment:主键ID"` // 主键ID
	RoomName string `json:"room_name" gorm:"not null;default:'';comment:房间名"`
	RoomType int8   `json:"room_type" gorm:"not null;default:0;comment:房间类型 1进线房 2机房"`
}

type QccReporter struct {
	ReporterId  uint   `gorm:"primary_key;AUTO_INCREMENT;comment:主键ID" json:"reporter_id"`
	Username    string `gorm:"type:varchar(50);comment:账号;NOT NULL" json:"username"`
	Name        string `gorm:"type:varchar(50);default:'';comment:名字;NOT NULL" json:"name"`
	Sex         int8   `gorm:"type:int(11);default:3;comment:性别 1男 2女 3其他" json:"sex"`
	PhoneNumber string `gorm:"type:varchar(20);default:'';comment:手机号（同账号）;NOT NULL" json:"phone_number"`
	Address     string `gorm:"type:text;default:'';comment:地址" json:"address"`
	Type        string `gorm:"type:varchar(50);default:'';comment:用户职责" json:"type"`
}
